// import { getCookie } from "./functionFromexport.js";

// const PhoneCookie = getCookie("phoneNumber");
const PhoneCookie = localStorage.getItem("phoneNumber");
// console.log("и снова",PhoneCookie);
// const clientGroupIdCookie = getCookie("clientGroupId");
const authButton = document.getElementById("auth");
const logInWindow = document.querySelector(".logInWindow");
const header = document.querySelector(".header");
const main = document.querySelector(".main");

const mButton = document.querySelectorAll(".mButton");

if (mButton != null) {
  for (let i = 0; i < mButton.length; i++) {
    // console.log(mButton[i].getAttribute("href"));
    mButton[i].addEventListener("click", (e) => {
      e.preventDefault();
      // console.log(mButton[i].getAttribute("href"));
      if (PhoneCookie == "n/a") {
        window.location.href = "/auth/";
      } else {
        window.location.href = mButton[i].getAttribute("href");
      }
    });
  }
}

if (PhoneCookie != null) {
  // console.log("заходит");
  if (PhoneCookie == "n/a") {
    if (authButton != null) {
      authButton.classList.remove("classHide");
    }
  } else {
    header.style.display = "flex";
    if (logInWindow != null) {
      logInWindow.classList.remove("classHide");
    }
    main.classList.add("addBorderRadius");
  }
}
